using System.Collections.Generic;

public class Table_SoundTempItem : IDataItem
{
	/// <summary>
	/// 唯一ID
	/// <summary>
	public int Id { get; private set; }
	/// <summary>
	/// 文件名称
	/// <summary>
	public string ResName { get; private set; }
	/// <summary>
	/// 音量
	/// <summary>
	public int Volume { get; private set; }
	/// <summary>
	/// 是否循环
	/// <summary>
	public bool IsLoop { get; private set; }
	/// <summary>
	/// 音效类型
	/// <summary>
	public int SoundType { get; private set; }
	/// <summary>
	/// 播放类型
	/// <summary>
	public int PlayType { get; private set; }
	/// <summary>
	/// 最大音量
	/// <summary>
	public int MinDis { get; private set; }
	/// <summary>
	/// 最小音量
	/// <summary>
	public int MaxDis { get; private set; }
	/// <summary>
	/// 音效点坐标
	/// <summary>
	public int GetPosCount() { return Pos.Count; }
	private List<int> Pos = new List<int>();
	public int GetPosByIndex(int idx)
	{
		return Pos.GetValueByIdx(idx, 0);
	}

	public Table_SoundTempItem(ExcelLineReader reader)
	{
		Id = reader.ReadInt();
		ResName = reader.ReadString();
		Volume = reader.ReadInt();
		IsLoop = reader.ReadBool();
		SoundType = reader.ReadInt();
		PlayType = reader.ReadInt();
		MinDis = reader.ReadInt();
		MaxDis = reader.ReadInt();
		Pos = reader.ReadShortString().ToIntList();
	}
}

public class Table_SoundTempMgr : IDataMgr
{
	protected override string FileName { get { return "Txt/SoundTemp.txt"; } }

	protected Dictionary<int, int> mItemDic = new Dictionary<int, int>();
	public int GetIdxById(int key) { return mItemDic[key]; }

	public override void Load(ExcelLineReader reader)
	{
		var item = new Table_SoundTempItem(reader);
		mItemDic[item.Id] = DataCount;
		mItemList.Add(item);
	}

	public Table_SoundTempItem GetItemByIdx(int idx)
	{
		return GetItemByIdx<Table_SoundTempItem>(idx);
	}

	public Table_SoundTempItem GetItemById(int id)
	{
		int idx = GetIdxById(id);
		return GetItemByIdx(idx);
	}
}